package com.wlient.basic.Thread.newThread;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class ImplementsCallable implements Callable {

    @Override
    public Object call() {
        System.out.println(Thread.currentThread().getName() + "--------callable线程工作中");
        return "实现callable，有返回值";
    }

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        for (int i = 0; i < 50; i++) {
            ImplementsCallable callable = new ImplementsCallable();
            FutureTask<String> task = new FutureTask<String>(callable);
            new Thread(task).start();
            System.out.println(task.get());
        }
    }
}